﻿#ifndef PST_TABLECHARTWINDOWSIDEBARDATA_H
#define PST_TABLECHARTWINDOWSIDEBARDATA_H

#include <QObject>
#include <QDomNodeList>
#include <QDomElement>
#include <QDomText>
#include <QDomAttr>
#include "BaseModule/GlobalHelper.h"
class QStandardItem;
namespace pst
{
    class TableChartWindowSidebarData :public QObject
    {
        Q_OBJECT

    public:
        TableChartWindowSidebarData(QObject* parent = nullptr);
        ~TableChartWindowSidebarData();

        struct TableDataitemInformation
        {
            QString m_itemName{""};
            int m_itemRowIndex{-1};
            bool m_itemDisplayStatus{true}; // true显示，false隐藏
            bool m_isReNamed{false};
            bool m_isEndWithKey{false};
        };

        void appendTableDataitemInformation(TableDataitemInformation dataitemInformation);
        QList<TableDataitemInformation>& getTableDataitemInformationList();
        void changeTableDataItemDisplayStatus(QSet<int> RowList);
        void changeTableDataItemName(QHash<int, QString> itemIndexAndName);

        void appendDataList(QHash<int, QStringList> hash);
        QHash<int, QStringList> getDataList();

        void clear();

        /// @brief 文件写出至工程文件
        QDomElement& writeToProjectFile(QDomDocument* doc, QDomElement* element, bool isdiso = false);
        /// @brief 从工程文件读入数据
        void readFromProjectFile(QDomElement* element, bool isdiso = false);

    private:
        // QList<TableDataitemInformation>转QString
        QString tableDataitemInformationListToString(QList<TableDataitemInformation> dataitemInformationList);
        // QString转QList<TableDataitemInformation>
        QList<TableDataitemInformation> stringToTableDataitemInformationList(QString dataitemInformationListString);

    private:
        QList<TableDataitemInformation> m_tableDataitemInformationList{};
        QHash<int, QStringList> m_dataHash{}; // index、选中的选项
    };
}
#endif
